/**  
 * All rights Reserved, Designed By <a href="www.itttq.com" target="_blank">www.itttq.com</a>
 * @date:   2017-07-21 11:42:21
 * @Copyright: 2017 <a href="www.itttq.com" target="_blank">www.itttq.com</a> Inc. All rights reserved. 
 */
package com.itttq.gshop.pbpm.mapper;

import java.util.List;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.DeleteProvider;
import org.apache.ibatis.annotations.InsertProvider;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.SelectProvider;
import org.apache.ibatis.annotations.UpdateProvider;

import com.itttq.gshop.domain.po.UserFavoritesPo;
import com.itttq.gshop.pbpm.provider.UserFavoritesSqlProvider;

@Mapper
public interface IUserFavoritesMapper {
	/**
	 * 新增UserFavoritesPo对象
	 * 
	 * @param UserFavoritesPo
	 * @Author 迷蝶
	 * @return Integer
	 */
	@InsertProvider(type=UserFavoritesSqlProvider.class,  method="addUserFavorites") 
	public Integer addUserFavorites(UserFavoritesPo userFavorites);

	/**
	 * 更新UserFavoritesPo对象
	 * 
	 * @param userFavoritesPo
	 * @Author 迷蝶
	 * @return Integer
	 */
	@UpdateProvider(type=UserFavoritesSqlProvider.class,  method="updateUserFavorites") 
	public Integer updateUserFavorites(UserFavoritesPo userFavorites);
	
	/**
	 * 根据ID删除UserFavoritesPo对象
	 * 
	 * @param id
	 * @Author 迷蝶
	 * @return Integer
	 */
	@DeleteProvider(type=UserFavoritesSqlProvider.class,  method="delUserFavorites") 
	public Integer delUserFavoritesById(Integer id);

	/**
	 * 根据IDS删除UserFavoritesPo对象
	 * 
	 * @param ids
	 * @Author 迷蝶
	 * @return List<UserFavoritesPo>
	 */
	@Delete("DELETE FROM user_favorites WHERE user_id=#{userId} AND id IN (${ids})")
	public Integer delFavoriteByIds(@Param("userId") int userId, @Param("ids") String ids);
	
	/**
	 * 根据条件查找UserFavoritesPo对象，默认根据ID降序
	 * 
	 * @param userFavoritesPo
	 * @Author 迷蝶
	 * @return List<UserFavoritesPo>
	 */
	@SelectProvider(type=UserFavoritesSqlProvider.class,  method="findUserFavoritess") 
	public List<UserFavoritesPo> findUserFavoritess(UserFavoritesPo userFavorites);
	
	/**
	 * 根据条件查找记录总数
	 * 
	 * @param userFavoritesPo
	 * @Author 迷蝶
	 * @return Integer
	 */
	@SelectProvider(type=UserFavoritesSqlProvider.class,  method="findUserFavoritesCount") 
	public Integer findUserFavoritesCount(UserFavoritesPo userFavorites);
	
	/**
	 * 根据ID查找UserFavoritesPo对象
	 * 
	 * @param id
	 * @Author 迷蝶
	 * @return UserFavoritesPo
	 */
	@SelectProvider(type=UserFavoritesSqlProvider.class,  method="findUserFavoritesById") 
	public UserFavoritesPo findUserFavoritesById(Integer id);

	/**
	 * 根据用户ID和商品ID删除收藏信息
	 * 
	 * @param wareId	商品ID
	 * @param userId		用户ID
	 * @Author 迷蝶
	 * @return Integer
	 */
	@Select("DELETE FROM user_favorites WHERE ware_id=#{wareId} and user_id=#{userId}")
	public Integer delFavoritesByUserId(@Param("wareId")Integer wareId, @Param("userId")Integer userId);
	
}